#[doc = "Register `I2C_COM` reader"]
pub struct R(crate::R<I2C_COM_SPEC>);
impl core::ops::Deref for R {
    type Target = crate::R<I2C_COM_SPEC>;
    #[inline(always)]
    fn deref(&self) -> &Self::Target {
        &self.0
    }
}
impl core::convert::From<crate::R<I2C_COM_SPEC>> for R {
    fn from(reader: crate::R<I2C_COM_SPEC>) -> Self {
        R(reader)
    }
}
#[doc = "Register `I2C_COM` writer"]
pub struct W(crate::W<I2C_COM_SPEC>);
impl core::ops::Deref for W {
    type Target = crate::W<I2C_COM_SPEC>;
    #[inline(always)]
    fn deref(&self) -> &Self::Target {
        &self.0
    }
}
impl core::ops::DerefMut for W {
    #[inline(always)]
    fn deref_mut(&mut self) -> &mut Self::Target {
        &mut self.0
    }
}
impl core::convert::From<crate::W<I2C_COM_SPEC>> for W {
    fn from(writer: crate::W<I2C_COM_SPEC>) -> Self {
        W(writer)
    }
}
#[doc = "Whether the master sends an ACK as a receiver.\n\nValue on reset: 0"]
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum OP_ACK_A {
    #[doc = "0: yes."]
    YES = 0,
    #[doc = "1: no."]
    NO = 1,
}
impl From<OP_ACK_A> for bool {
    #[inline(always)]
    fn from(variant: OP_ACK_A) -> Self {
        variant as u8 != 0
    }
}
#[doc = "Field `op_ack` reader - Whether the master sends an ACK as a receiver."]
pub struct OP_ACK_R(crate::FieldReader<bool, OP_ACK_A>);
impl OP_ACK_R {
    pub(crate) fn new(bits: bool) -> Self {
        OP_ACK_R(crate::FieldReader::new(bits))
    }
    #[doc = r"Get enumerated values variant"]
    #[inline(always)]
    pub fn variant(&self) -> OP_ACK_A {
        match self.bits {
            false => OP_ACK_A::YES,
            true => OP_ACK_A::NO,
        }
    }
    #[doc = "Checks if the value of the field is `YES`"]
    #[inline(always)]
    pub fn is_yes(&self) -> bool {
        **self == OP_ACK_A::YES
    }
    #[doc = "Checks if the value of the field is `NO`"]
    #[inline(always)]
    pub fn is_no(&self) -> bool {
        **self == OP_ACK_A::NO
    }
}
impl core::ops::Deref for OP_ACK_R {
    type Target = crate::FieldReader<bool, OP_ACK_A>;
    #[inline(always)]
    fn deref(&self) -> &Self::Target {
        &self.0
    }
}
#[doc = "Field `op_ack` writer - Whether the master sends an ACK as a receiver."]
pub struct OP_ACK_W<'a> {
    w: &'a mut W,
}
impl<'a> OP_ACK_W<'a> {
    #[doc = r"Writes `variant` to the field"]
    #[inline(always)]
    pub fn variant(self, variant: OP_ACK_A) -> &'a mut W {
        self.bit(variant.into())
    }
    #[doc = "yes."]
    #[inline(always)]
    pub fn yes(self) -> &'a mut W {
        self.variant(OP_ACK_A::YES)
    }
    #[doc = "no."]
    #[inline(always)]
    pub fn no(self) -> &'a mut W {
        self.variant(OP_ACK_A::NO)
    }
    #[doc = r"Sets the field bit"]
    #[inline(always)]
    pub fn set_bit(self) -> &'a mut W {
        self.bit(true)
    }
    #[doc = r"Clears the field bit"]
    #[inline(always)]
    pub fn clear_bit(self) -> &'a mut W {
        self.bit(false)
    }
    #[doc = r"Writes raw bits to the field"]
    #[inline(always)]
    pub fn bit(self, value: bool) -> &'a mut W {
        self.w.bits = (self.w.bits & !(0x01 << 4)) | (((value as u32) & 0x01) << 4);
        self.w
    }
}
#[doc = "Generation of the start condition.\n\nValue on reset: 0"]
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum OP_START_A {
    #[doc = "0: The operation is complete."]
    COMPLETE = 0,
    #[doc = "1: The operation is valid."]
    VALID = 1,
}
impl From<OP_START_A> for bool {
    #[inline(always)]
    fn from(variant: OP_START_A) -> Self {
        variant as u8 != 0
    }
}
#[doc = "Field `op_start` reader - Generation of the start condition."]
pub struct OP_START_R(crate::FieldReader<bool, OP_START_A>);
impl OP_START_R {
    pub(crate) fn new(bits: bool) -> Self {
        OP_START_R(crate::FieldReader::new(bits))
    }
    #[doc = r"Get enumerated values variant"]
    #[inline(always)]
    pub fn variant(&self) -> OP_START_A {
        match self.bits {
            false => OP_START_A::COMPLETE,
            true => OP_START_A::VALID,
        }
    }
    #[doc = "Checks if the value of the field is `COMPLETE`"]
    #[inline(always)]
    pub fn is_complete(&self) -> bool {
        **self == OP_START_A::COMPLETE
    }
    #[doc = "Checks if the value of the field is `VALID`"]
    #[inline(always)]
    pub fn is_valid(&self) -> bool {
        **self == OP_START_A::VALID
    }
}
impl core::ops::Deref for OP_START_R {
    type Target = crate::FieldReader<bool, OP_START_A>;
    #[inline(always)]
    fn deref(&self) -> &Self::Target {
        &self.0
    }
}
#[doc = "Field `op_start` writer - Generation of the start condition."]
pub struct OP_START_W<'a> {
    w: &'a mut W,
}
impl<'a> OP_START_W<'a> {
    #[doc = r"Writes `variant` to the field"]
    #[inline(always)]
    pub fn variant(self, variant: OP_START_A) -> &'a mut W {
        self.bit(variant.into())
    }
    #[doc = "The operation is complete."]
    #[inline(always)]
    pub fn complete(self) -> &'a mut W {
        self.variant(OP_START_A::COMPLETE)
    }
    #[doc = "The operation is valid."]
    #[inline(always)]
    pub fn valid(self) -> &'a mut W {
        self.variant(OP_START_A::VALID)
    }
    #[doc = r"Sets the field bit"]
    #[inline(always)]
    pub fn set_bit(self) -> &'a mut W {
        self.bit(true)
    }
    #[doc = r"Clears the field bit"]
    #[inline(always)]
    pub fn clear_bit(self) -> &'a mut W {
        self.bit(false)
    }
    #[doc = r"Writes raw bits to the field"]
    #[inline(always)]
    pub fn bit(self, value: bool) -> &'a mut W {
        self.w.bits = (self.w.bits & !(0x01 << 3)) | (((value as u32) & 0x01) << 3);
        self.w
    }
}
#[doc = "Generation of the read operation.\n\nValue on reset: 0"]
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum OP_RD_A {
    #[doc = "0: The operation is complete."]
    COMPLETE = 0,
    #[doc = "1: The operation is valid."]
    VALID = 1,
}
impl From<OP_RD_A> for bool {
    #[inline(always)]
    fn from(variant: OP_RD_A) -> Self {
        variant as u8 != 0
    }
}
#[doc = "Field `op_rd` reader - Generation of the read operation."]
pub struct OP_RD_R(crate::FieldReader<bool, OP_RD_A>);
impl OP_RD_R {
    pub(crate) fn new(bits: bool) -> Self {
        OP_RD_R(crate::FieldReader::new(bits))
    }
    #[doc = r"Get enumerated values variant"]
    #[inline(always)]
    pub fn variant(&self) -> OP_RD_A {
        match self.bits {
            false => OP_RD_A::COMPLETE,
            true => OP_RD_A::VALID,
        }
    }
    #[doc = "Checks if the value of the field is `COMPLETE`"]
    #[inline(always)]
    pub fn is_complete(&self) -> bool {
        **self == OP_RD_A::COMPLETE
    }
    #[doc = "Checks if the value of the field is `VALID`"]
    #[inline(always)]
    pub fn is_valid(&self) -> bool {
        **self == OP_RD_A::VALID
    }
}
impl core::ops::Deref for OP_RD_R {
    type Target = crate::FieldReader<bool, OP_RD_A>;
    #[inline(always)]
    fn deref(&self) -> &Self::Target {
        &self.0
    }
}
#[doc = "Field `op_rd` writer - Generation of the read operation."]
pub struct OP_RD_W<'a> {
    w: &'a mut W,
}
impl<'a> OP_RD_W<'a> {
    #[doc = r"Writes `variant` to the field"]
    #[inline(always)]
    pub fn variant(self, variant: OP_RD_A) -> &'a mut W {
        self.bit(variant.into())
    }
    #[doc = "The operation is complete."]
    #[inline(always)]
    pub fn complete(self) -> &'a mut W {
        self.variant(OP_RD_A::COMPLETE)
    }
    #[doc = "The operation is valid."]
    #[inline(always)]
    pub fn valid(self) -> &'a mut W {
        self.variant(OP_RD_A::VALID)
    }
    #[doc = r"Sets the field bit"]
    #[inline(always)]
    pub fn set_bit(self) -> &'a mut W {
        self.bit(true)
    }
    #[doc = r"Clears the field bit"]
    #[inline(always)]
    pub fn clear_bit(self) -> &'a mut W {
        self.bit(false)
    }
    #[doc = r"Writes raw bits to the field"]
    #[inline(always)]
    pub fn bit(self, value: bool) -> &'a mut W {
        self.w.bits = (self.w.bits & !(0x01 << 2)) | (((value as u32) & 0x01) << 2);
        self.w
    }
}
#[doc = "Generation of the write operation.\n\nValue on reset: 0"]
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum OP_WE_A {
    #[doc = "0: The operation is complete."]
    COMPLETE = 0,
    #[doc = "1: The operation is valid."]
    VALID = 1,
}
impl From<OP_WE_A> for bool {
    #[inline(always)]
    fn from(variant: OP_WE_A) -> Self {
        variant as u8 != 0
    }
}
#[doc = "Field `op_we` reader - Generation of the write operation."]
pub struct OP_WE_R(crate::FieldReader<bool, OP_WE_A>);
impl OP_WE_R {
    pub(crate) fn new(bits: bool) -> Self {
        OP_WE_R(crate::FieldReader::new(bits))
    }
    #[doc = r"Get enumerated values variant"]
    #[inline(always)]
    pub fn variant(&self) -> OP_WE_A {
        match self.bits {
            false => OP_WE_A::COMPLETE,
            true => OP_WE_A::VALID,
        }
    }
    #[doc = "Checks if the value of the field is `COMPLETE`"]
    #[inline(always)]
    pub fn is_complete(&self) -> bool {
        **self == OP_WE_A::COMPLETE
    }
    #[doc = "Checks if the value of the field is `VALID`"]
    #[inline(always)]
    pub fn is_valid(&self) -> bool {
        **self == OP_WE_A::VALID
    }
}
impl core::ops::Deref for OP_WE_R {
    type Target = crate::FieldReader<bool, OP_WE_A>;
    #[inline(always)]
    fn deref(&self) -> &Self::Target {
        &self.0
    }
}
#[doc = "Field `op_we` writer - Generation of the write operation."]
pub struct OP_WE_W<'a> {
    w: &'a mut W,
}
impl<'a> OP_WE_W<'a> {
    #[doc = r"Writes `variant` to the field"]
    #[inline(always)]
    pub fn variant(self, variant: OP_WE_A) -> &'a mut W {
        self.bit(variant.into())
    }
    #[doc = "The operation is complete."]
    #[inline(always)]
    pub fn complete(self) -> &'a mut W {
        self.variant(OP_WE_A::COMPLETE)
    }
    #[doc = "The operation is valid."]
    #[inline(always)]
    pub fn valid(self) -> &'a mut W {
        self.variant(OP_WE_A::VALID)
    }
    #[doc = r"Sets the field bit"]
    #[inline(always)]
    pub fn set_bit(self) -> &'a mut W {
        self.bit(true)
    }
    #[doc = r"Clears the field bit"]
    #[inline(always)]
    pub fn clear_bit(self) -> &'a mut W {
        self.bit(false)
    }
    #[doc = r"Writes raw bits to the field"]
    #[inline(always)]
    pub fn bit(self, value: bool) -> &'a mut W {
        self.w.bits = (self.w.bits & !(0x01 << 1)) | (((value as u32) & 0x01) << 1);
        self.w
    }
}
#[doc = "Generation of the stop condition.\n\nValue on reset: 0"]
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum OP_STOP_A {
    #[doc = "0: The operation is complete."]
    COMPLETE = 0,
    #[doc = "1: The operation is valid."]
    VALID = 1,
}
impl From<OP_STOP_A> for bool {
    #[inline(always)]
    fn from(variant: OP_STOP_A) -> Self {
        variant as u8 != 0
    }
}
#[doc = "Field `op_stop` reader - Generation of the stop condition."]
pub struct OP_STOP_R(crate::FieldReader<bool, OP_STOP_A>);
impl OP_STOP_R {
    pub(crate) fn new(bits: bool) -> Self {
        OP_STOP_R(crate::FieldReader::new(bits))
    }
    #[doc = r"Get enumerated values variant"]
    #[inline(always)]
    pub fn variant(&self) -> OP_STOP_A {
        match self.bits {
            false => OP_STOP_A::COMPLETE,
            true => OP_STOP_A::VALID,
        }
    }
    #[doc = "Checks if the value of the field is `COMPLETE`"]
    #[inline(always)]
    pub fn is_complete(&self) -> bool {
        **self == OP_STOP_A::COMPLETE
    }
    #[doc = "Checks if the value of the field is `VALID`"]
    #[inline(always)]
    pub fn is_valid(&self) -> bool {
        **self == OP_STOP_A::VALID
    }
}
impl core::ops::Deref for OP_STOP_R {
    type Target = crate::FieldReader<bool, OP_STOP_A>;
    #[inline(always)]
    fn deref(&self) -> &Self::Target {
        &self.0
    }
}
#[doc = "Field `op_stop` writer - Generation of the stop condition."]
pub struct OP_STOP_W<'a> {
    w: &'a mut W,
}
impl<'a> OP_STOP_W<'a> {
    #[doc = r"Writes `variant` to the field"]
    #[inline(always)]
    pub fn variant(self, variant: OP_STOP_A) -> &'a mut W {
        self.bit(variant.into())
    }
    #[doc = "The operation is complete."]
    #[inline(always)]
    pub fn complete(self) -> &'a mut W {
        self.variant(OP_STOP_A::COMPLETE)
    }
    #[doc = "The operation is valid."]
    #[inline(always)]
    pub fn valid(self) -> &'a mut W {
        self.variant(OP_STOP_A::VALID)
    }
    #[doc = r"Sets the field bit"]
    #[inline(always)]
    pub fn set_bit(self) -> &'a mut W {
        self.bit(true)
    }
    #[doc = r"Clears the field bit"]
    #[inline(always)]
    pub fn clear_bit(self) -> &'a mut W {
        self.bit(false)
    }
    #[doc = r"Writes raw bits to the field"]
    #[inline(always)]
    pub fn bit(self, value: bool) -> &'a mut W {
        self.w.bits = (self.w.bits & !0x01) | ((value as u32) & 0x01);
        self.w
    }
}
impl R {
    #[doc = "Bit 4 - Whether the master sends an ACK as a receiver."]
    #[inline(always)]
    pub fn op_ack(&self) -> OP_ACK_R {
        OP_ACK_R::new(((self.bits >> 4) & 0x01) != 0)
    }
    #[doc = "Bit 3 - Generation of the start condition."]
    #[inline(always)]
    pub fn op_start(&self) -> OP_START_R {
        OP_START_R::new(((self.bits >> 3) & 0x01) != 0)
    }
    #[doc = "Bit 2 - Generation of the read operation."]
    #[inline(always)]
    pub fn op_rd(&self) -> OP_RD_R {
        OP_RD_R::new(((self.bits >> 2) & 0x01) != 0)
    }
    #[doc = "Bit 1 - Generation of the write operation."]
    #[inline(always)]
    pub fn op_we(&self) -> OP_WE_R {
        OP_WE_R::new(((self.bits >> 1) & 0x01) != 0)
    }
    #[doc = "Bit 0 - Generation of the stop condition."]
    #[inline(always)]
    pub fn op_stop(&self) -> OP_STOP_R {
        OP_STOP_R::new((self.bits & 0x01) != 0)
    }
}
impl W {
    #[doc = "Bit 4 - Whether the master sends an ACK as a receiver."]
    #[inline(always)]
    pub fn op_ack(&mut self) -> OP_ACK_W {
        OP_ACK_W { w: self }
    }
    #[doc = "Bit 3 - Generation of the start condition."]
    #[inline(always)]
    pub fn op_start(&mut self) -> OP_START_W {
        OP_START_W { w: self }
    }
    #[doc = "Bit 2 - Generation of the read operation."]
    #[inline(always)]
    pub fn op_rd(&mut self) -> OP_RD_W {
        OP_RD_W { w: self }
    }
    #[doc = "Bit 1 - Generation of the write operation."]
    #[inline(always)]
    pub fn op_we(&mut self) -> OP_WE_W {
        OP_WE_W { w: self }
    }
    #[doc = "Bit 0 - Generation of the stop condition."]
    #[inline(always)]
    pub fn op_stop(&mut self) -> OP_STOP_W {
        OP_STOP_W { w: self }
    }
    #[doc = "Writes raw bits to the register."]
    pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
        self.0.bits(bits);
        self
    }
}
#[doc = "I2C_COM is the I2C command register. It is used to configure the commands for the working of the I2C module.\n\nThis register you can [`read`](crate::generic::Reg::read), [`write_with_zero`](crate::generic::Reg::write_with_zero), [`reset`](crate::generic::Reg::reset), [`write`](crate::generic::Reg::write), [`modify`](crate::generic::Reg::modify). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [i2c_com](index.html) module"]
pub struct I2C_COM_SPEC;
impl crate::RegisterSpec for I2C_COM_SPEC {
    type Ux = u32;
}
#[doc = "`read()` method returns [i2c_com::R](R) reader structure"]
impl crate::Readable for I2C_COM_SPEC {
    type Reader = R;
}
#[doc = "`write(|w| ..)` method takes [i2c_com::W](W) writer structure"]
impl crate::Writable for I2C_COM_SPEC {
    type Writer = W;
}
#[doc = "`reset()` method sets I2C_COM to value 0"]
impl crate::Resettable for I2C_COM_SPEC {
    #[inline(always)]
    fn reset_value() -> Self::Ux {
        0
    }
}
